package com.idealighter.game.gamerecord.convert;

import com.idealighter.game.core.convert.DateLongValueConvert;
import com.idealighter.game.gamerecord.dto.GameRoomInfoDto;
import com.idealighter.game.gamerecord.dto.GameRoundInfoDto;
import com.idealighter.game.gamerecord.dto.GameScoreInfoDto;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardNiuniuScoreDetailsDomain;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardRoomListDomain;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardScoreDomain;

import java.util.List;

import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueMappingStrategy;
import org.mapstruct.factory.Mappers;

@Mapper(uses = DateLongValueConvert.class)
public interface GameRecordDtoConvert {

  GameRecordDtoConvert INSTANCE = Mappers.getMapper(GameRecordDtoConvert.class);

  @Mapping(target = "playerSuperId", source = "superId")
  GameScoreInfoDto toGameScoreInfoDto(RoomCardScoreDomain scoreDomain);

  @IterableMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
  List<GameScoreInfoDto> toGameScoreInfoDtos(List<RoomCardScoreDomain> scoreDomains);

  @Mapping(target = "roomId", source = "roomListDomain.id")
  @Mapping(target = "ownerId", source = "roomListDomain.playerId")
  @Mapping(target = "ownerSuperId", source = "roomListDomain.superId")
  @Mapping(target = "rounds", source = "roomListDomain.playGames")
  @Mapping(target = "scoreList", ignore = true)
  GameRoomInfoDto toGameRoomInfoDto(RoomCardRoomListDomain roomListDomain);

  GameRoundInfoDto toGameRoundInfoDto(RoomCardNiuniuScoreDetailsDomain pojo);
}
